//
//  ClubLoginVerfityViewController.swift
//  77Club
//
//  Created by Apple on 2024/9/20.
//

import UIKit

class ClubLoginVerfityViewController: ClubBaseViewController {

    private let bgView = c_make_ex(UIImageView.self)
        .image("Login_bg").mode(.scaleAspectFill).end()
    private let backButton = c_make_ex(UIButton.self)
        .image("Common_blackBack").end()
    private let titleLabel = c_make_ex(UILabel.self)
        .text("账号验证").color(.black).font(16.font_semiBold).end()
    private var phoneButton = c_make_ex(UIButton.self)
        .bgColor(.white).corner(8).end()
    private var emailButton = c_make_ex(UIButton.self)
        .bgColor(.white).corner(8).end()
    private var serviceButton = c_make_ex(UIButton.self)
        .text("无法验证？联系在线客服").color("#47494D")
        .font(12.font_medium).end()
    
    override func viewDidLoad() {
        super.viewDidLoad()

        view.subviews{
            bgView
            backButton
            titleLabel
            phoneButton
            emailButton
            serviceButton
        }
        
        bgView.fillContainer()
        backButton.leading(0).top(.statusHeight).width(56).height(44)
        titleLabel.leading(56)
        titleLabel.CenterY == backButton.CenterY
        phoneButton.leading(12.0.Scale).trailing(12.0.Scale).top(.navi_height + 24.0.Scale).height(68.0.Scale)
        emailButton.leading(12.0.Scale).trailing(12.0.Scale).height(68.0.Scale)
        emailButton.Top == phoneButton.Bottom + 24.0.Scale
        serviceButton.centerHorizontally()
        serviceButton.Top == emailButton.Bottom + 24.0.Scale
        
        setupButton(button: phoneButton, title: "通过手机号验证", subTitle: "可通过手机号验证+短信验证码登录")
        setupButton(button: emailButton, title: "通过邮箱验证", subTitle: "可通过邮箱地址重设密码")
        
        backButton.addTarget(self, action: #selector(clickBackButton), for: .touchUpInside)
        phoneButton.addTarget(self, action: #selector(clickPhoneButton), for: .touchUpInside)
        emailButton.addTarget(self, action: #selector(clickEmailButton), for: .touchUpInside)
        
    }

    
    private func setupButton(button: UIButton, title: String, subTitle: String) {
        
        let titleLabel = UILabel(frame: CGRect(x: 16.0.Scale, y: 16.0.Scale, width: 150, height: 14.0.Scale))
        titleLabel.text = title
        titleLabel.textColor = "#2E3033".toColor
        titleLabel.font = 14.font_semiBold
        button.addSubview(titleLabel)
        
        let subLabel = UILabel(frame: CGRect(x: 16.0.Scale, y: 38.0.Scale, width: 250, height: 14.0.Scale))
        subLabel.text = subTitle
        subLabel.textColor = "#7B7D80".toColor
        subLabel.font = 14.font_medium
        button.addSubview(subLabel)
        
        let rightImageV = UIImageView(frame: CGRect(x: 315.0.Scale, y: 24.0.Scale, width: 20, height: 20))
        rightImageV.image = "Mine_settings_next".toImage
        button.addSubview(rightImageV)
    }
    
    @objc private func clickPhoneButton(){
        
        let forgetVC = ClubForgetPasswordViewController()
        forgetVC.type = 0
        self.navigationController?.pushViewController(forgetVC, animated: true)
    }
    
    @objc private func clickEmailButton(){
        
        let forgetVC = ClubForgetPasswordViewController()
        forgetVC.type = 1
        self.navigationController?.pushViewController(forgetVC, animated: true)
    }
    
    override func viewDidLayoutSubviews() {
        super.viewDidLayoutSubviews()
        
        
    }
}
